package com.ruoyi.web.controller.net;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.net.domain.*;
import com.ruoyi.net.netconf.util.DeviceManager;
import com.ruoyi.net.service.*;
import com.ruoyi.system.service.ISysConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 业务-MTN Channel配置Controller
 * 
 * @author net
 * @date 2024-12-08
 */
@Api(tags = "业务-MTN Channel配置")
@RestController
@RequestMapping("/busi/mtn/channel")
public class BusiMtnChannelController extends BaseController
{
    @Autowired
    private IBusiMtnChannelService busiMtnChannelService;
    @Autowired
    private DeviceManager deviceManager;

    @Autowired
    private ISysConfigService sysConfigService;

    @Autowired
    private INetElementService netElementService;

    @Autowired
    private IBusiMtnChannelRouteGraphService busiMtnChannelRouteGraphService;
    @Autowired
    private IBusiMtnChannelRouteTableService busiMtnChannelRouteTableService;
    @Autowired
    private IElementBusiMtnclientFgService elementBusiMtnclientFgService;


    @Autowired
    private IElementPortEthService elementPortEthService;
    /**
     * 查询业务-MTN Channel配置列表
     */
    @ApiOperation(value = "查询业务-MTN Channel配置列表", httpMethod = "GET")
    @PreAuthorize("@ss.hasPermi('net:channel:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusiMtnChannel busiMtnChannel)
    {
        startPage();
        List<BusiMtnChannelListVo> list = busiMtnChannelService.selectBusiMtnChannelList(busiMtnChannel);
        return getDataTable(list);
    }
    /**
     * 查询网元-MTN client列表
     */
    @ApiOperation(value = "查询网元-MTN client列表", httpMethod = "GET")
    @PreAuthorize("@ss.hasPermi('net:channel:list')")
    @GetMapping("/ele/clientList")
    public TableDataInfo clientList(BusiMtnChannelListVo busiMtnChannel)
    {
        startPage();
        busiMtnChannel.setMtnType("MTN Channel");
        List<BusiMtnChannelListVo> list = busiMtnChannelService.selectBusiMtnChannelClientList(busiMtnChannel);
        return getDataTable(list);
    }
    /**
     * 查询网元-MTN FG client列表
     */
    @ApiOperation(value = "查询网元-MTN FG client列表", httpMethod = "GET")
    @PreAuthorize("@ss.hasPermi('net:channel:list')")
    @GetMapping("/ele/fgClientList")
    public TableDataInfo fgClientList(BusiMtnChannelListVo busiMtnChannel)
    {
        startPage();
        busiMtnChannel.setMtnType("MTN FG-Channel");
        List<BusiMtnChannelListVo> list = busiMtnChannelService.selectBusiMtnChannelClientList(busiMtnChannel);
        return getDataTable(list);
    }
    /**
     * 导出业务-MTN Channel配置列表
     */
    @ApiOperation(value = "导出业务-MTN Channel配置列表", httpMethod = "POST")
    @PreAuthorize("@ss.hasPermi('net:channel:export')")
    @Log(title = "业务-MTN Channel配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusiMtnChannel busiMtnChannel)
    {
        List<BusiMtnChannelListVo> list = busiMtnChannelService.selectBusiMtnChannelList(busiMtnChannel);
        ExcelUtil<BusiMtnChannelListVo> util = new ExcelUtil<BusiMtnChannelListVo>(BusiMtnChannelListVo.class);
        util.exportExcel(response, list, "业务-MTN Channel配置数据");
    }

    /**
     * 获取业务-MTN Channel配置详细信息
     */
    @ApiOperation(value = "获取业务-MTN Channel配置详细信息", httpMethod = "GET")
    @PreAuthorize("@ss.hasPermi('net:channel:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(busiMtnChannelService.selectBusiMtnChannelById(id));
    }

    /**
     * 新增业务-MTN Channel配置
     */
    @ApiOperation(value = "新增业务-MTN Channel配置", httpMethod = "POST")
    @PreAuthorize("@ss.hasPermi('net:channel:add')")
    @Log(title = "业务-MTN Channel配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusiMtnChannelVo busiMtnChannelVo)
    {
        return toAjax(busiMtnChannelService.insertBusiMtnChannel(busiMtnChannelVo));
    }

    /**
     * 修改业务-MTN Channel配置
     */
    @ApiOperation(value = "修改业务-MTN Channel配置", httpMethod = "PUT")
    @PreAuthorize("@ss.hasPermi('net:channel:edit')")
    @Log(title = "业务-MTN Channel配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusiMtnChannel busiMtnChannel)
    {
        return toAjax(busiMtnChannelService.updateBusiMtnChannel(busiMtnChannel));
    }

    /**
     * 删除业务-MTN Channel配置
     */
    @ApiOperation(value = "删除业务-MTN Channel配置", httpMethod = "DELETE")
    @PreAuthorize("@ss.hasPermi('net:channel:remove')")
    @Log(title = "业务-MTN Channel配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(busiMtnChannelService.deleteBusiMtnChannelByIds(ids));
    }

}
